//逻辑类， 处理网络层收到的数据
#ifndef LOG_H
#define LOG_H

#include "signal.h"
#include "server.h"
#include "my_global.h"

#include <atomic>
#include <cstdint>
#include <thread>
#include <queue>
#include <functional>
#include <map>



using FunCallBack = 
    std::function<void(std::shared_ptr<Session>, const uint32_t&, const std::string&)>;

class Logic
{
public:
    Logic();
    ~Logic();

    void AddMagQueue(std::shared_ptr<LogicNode> node);
private:
    //注册回调函数
    void RegisterFunc();
    //线程处理函数
    void Work();

    //对应消息id的处理函数 1001
    void HelloWorldCallBack(std::shared_ptr<Session> session, const uint32_t& msg_id, const std::string& msg_data);

private:
    std::condition_variable m_cv;
    std::mutex m_queue_mutex;
    std::queue<std::shared_ptr<LogicNode>> m_msg_que;
    std::thread m_work_thread;
    std::atomic_bool m_is_stop;
    std::map<uint32_t, FunCallBack> m_func_map;
};


#endif // LOG_H